package com.xyzwps.server.paimon.model.table

import com.xyzwps.server.paimon.model.entity.PhoneVcode
import org.jetbrains.exposed.v1.core.dao.id.LongIdTable
import org.jetbrains.exposed.v1.datetime.CurrentTimestamp
import org.jetbrains.exposed.v1.datetime.timestamp

object PhoneVcodeTable : LongIdTable("phone_vcode") {
    val phone = varchar("phone", PhoneVcode.PHONE_MAX_LENGTH)
    val scene = integer("scene")
    val vcode = varchar("vcode", PhoneVcode.VCODE_MAX_LENGTH)
    val dkey = varchar("dkey", PhoneVcode.DKEY_MAX_LENGTH)
    val createdAt = timestamp("created_at").defaultExpression(CurrentTimestamp)
    val used = bool("used").default(false)
    val usedAt = timestamp("used_at").nullable()

    init {
        index(customIndexName = "uk_phone_scene_dkey", true, dkey, phone, scene)
        index(customIndexName = "idx_phone", true, phone)
    }
}